<!doctype html>
<html>

<head>
  <!--<script>-->
  <!--document.documentElement.style.fontSize = document.documentElement.clientWidth / 6.4 + 'px';-->
  <!--</script>-->
  <meta charset="UTF-8">
  <title></title>
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  <link href="../../css/mui.min.css" rel="stylesheet" />
  <link href="../../css/mui.picker.css" rel="stylesheet" />
  <link href="../../css/mui.poppicker.css" rel="stylesheet" />
  <link href="../../css/mui.dtpicker.css" rel="stylesheet" />
  <link rel="stylesheet" type="text/css" href="../../fonts/iconfont.css" />
  <link rel="stylesheet" type="text/css" href="../../css/timecheck.css" />
  <script src="../../config.js"></script>
  <script>
    var width =window.localStorage.getItem('width');
    document.documentElement.style.fontSize =  width ? width/6.4+  'px' :'55px';
  </script>

  <style>
    .tab{
      width: 100%;
      background-color: #FFFFFF;
      overflow: hidden;
      position: fixed;
      top:0;
      z-index: 99999;
    }
    .tab p{
      float: left;
      width: 2rem;
      padding: 0.1rem 0;
      margin: 0;
      text-align: center;
      font-size: 0.26rem;
    }
    .tab .default{
      color:#ED7D31;
      border-bottom: 1px solid #ED7D31;
    }
    .calendarDiv{
      width: 100%;
      background-color: white;
      font-size: 0.26rem;
    }
    table {
      font-size: 0.24rem;
      width: 100%;
      text-align: center;
    }
    .calendarTitle{
      width: 100%;
      position: relative;
    }
    .calendarTitle span{
      display: inline-block;
      text-align: center;
      float: left;
      padding: 0.1rem 0;
    }
    .calendarTitle span img{
      width: 0.2rem;
    }
    .calendarTitle .lastYear ,.calendarTitle .nextYear {
      width: 20%;
    }
    .time{
      width: 40%;
    }
    .lastMonth,.nextMonth{
      width: 10%;
    }
    .calendarTitle .lastYear img,.calendarTitle .nextYear img{
      width: 0.25rem;
      position: absolute;
      top:0.14rem;
    }
    .calendarTitle .lastMonth{
      text-align:left ;
    }
    .calendarTitle .nextMonth{
      text-align:right ;
    }
    .timeList{
      margin-bottom: 0.1rem;
    }
    .timeList td{
      height: 0.8rem;
      position: relative;
      padding: 0;
    }

    .timeList td .activityNum{
      display: inline-block;
      background-color: #4472C4;
      width: 0.25rem;
      height: 0.25rem;
      /*border-radius: 0.15rem;*/
      text-align: center;
      line-height: 0.3rem;
      color:white;
      position: absolute;
      top:0;
      right:0;
      font-size: 0.16rem;
    }
    .timeList td .activityNum2{
      display: inline-block;
      background-color: #ccc;
      width: 0.25rem;
      height: 0.25rem;
      /*border-radius: 0.15rem;*/
      text-align: center;
      line-height: 0.3rem;
      color:white;
      position: absolute;
      top:0;
      right:0;
      font-size: 0.16rem;
    }

    .timeList td {
      border: 1px solid #ccc;
    }
    .timeList .today{
      background-color: #ED7D31; !important;
    }
    table .timeList .nowDay{
      /*border: 1px solid #ED7D31; !important;*/
      background-color: rgba(237, 125, 49, 0.28); !important;
    }
    .date{
      display: inline-block;
      position: absolute;
      top: 0;
      left: 0.3rem;
    }

    .lineDiv{
      overflow: hidden;
      position: absolute;
      bottom:0;
      width: 100%;
      height: 0.45rem;
    }
    .line2{
      height: 0.12rem;
    }
    .line2 div,.line2 .lineBody{
      float: left;
    }
    .lineHeader{
      width: 5px;
      height: 5px;
      border-radius: 2.5px;
      /*background-color: #0066CC;*/
      margin: 0 0 0 10%;
    }

    .line2 .lineBodyWidth{
      width: 80%;
    }
    .line2 .lineBodyWidth2{
      width: 60%; !important;
    }
    .lineBody{
      /*height:1px;*/
      border:none;
      /*border-top:1px dashed #0066CC;*/
      width: 100%;
      margin: 2px 0 0 0;
    }
    .lineFooter{
      width:1px;
      height: 5px;
      /*background-color: #0066CC;*/
      /*margin-right: 15% ;*/
    }


    .activity{
      background-color: rgba(204, 204, 204, 0.29);

    }
    .table-box{
      width: 100%;
      font-size: 0.2rem;
      text-align: center;
      padding-bottom: 1rem;
      margin-top: 0.2rem;
    }
    .tab-head {
      width: 100%;
      background-color: #FFFFFF;
      line-height: 0.5rem;
    }
    .light {
      color: #8e8a8a;
    }
    .bglight {
      background-color: #FFFFFF;
    }
    table {
      font-size: 0.22rem;
      width: 100%;
      text-align: center;
      margin-top: 0.1rem;
    }
    table tr td {
      padding: 0.1rem 0;
      height: 0.8rem;
    }
    .activityDiv{
      width: 96%;
      margin: 0.3rem auto 0;
      border: 1px dotted black;
      background-color: white;
      border-radius: 0.3rem;
      padding: 0.2rem 0.2rem 0;
      overflow: hidden;
    }
    .activityName{
      width: 100%;
      position: relative;
    }
    .activityName img{
      position: absolute;
      top:0.03rem;
      width: 0.3rem;
    }
    .activityName p{
      float: left;
      margin: 0 0 0 0.4rem;
      font-size: 0.26rem;
      color:black;
    }
    .introduce{
      clear: both;
      font-size: 0.22rem;
      padding-top: 0.2rem;
      margin: 0;
    }
    .planDiv{
      width: 110%;
      border-top: 1px dotted #ccc;
      position: relative;
      left: -0.4rem;
      margin-top: 0.1rem;
      overflow: hidden;
    }
    .planDiv p{
      width: 1.6rem;
      float: right;
      margin: 0;
      text-align: center;
      padding: 0.1rem 0 ;
    }
    .titleDiv{
      width: 90%;
      margin: 0.4rem auto 0;
      text-align: center;
      font-size: 0.25rem;
      position: relative;

    }
    .titleDiv .line{
      display: inline-block;
      background-color: white;
      width: 30%;
      height: 1px;
    }
    .titleDiv .line:first-child{
      position: absolute;
      top:0.28rem;
      left: 0.1rem;
    }
    .titleDiv .line:last-child{
      position: absolute;
      top:0.28rem;
      right: 0.1rem;
    }
    .titleDiv .title{
      display: inline-block;
      width: 40%;
      background-color: white;
      height: 0.6rem;
      line-height: 0.6rem;
      border-radius: 0.3rem;
    }



    .fade-enter-active, .fade-leave-active {
      transition: width .5s
    }
    .fade-enter, .fade-leave-to {
      width: 200%
    }
    .float{
      float:left;
    }


    .sign1{
      display: inline-block;
      width: 12px;
      height: 12px;
      border-radius:6px;
      /*background-color: #2ac845;*/
      position: absolute;
      top:0.33rem;
      left: 0.1rem;

    }



  </style>
</head>

<body>
<div id="app" class="mui-content">

  <!--选项卡-->
  <div class="tab">
    <p @click="choose(1)" :class="{default:chooseType ===1}">活动计划</p>
    <p @click="choose(2)" :class="{default:chooseType ===2}">活动池</p>
  </div>
  <!--活动计划-->
  <div v-show="chooseType ===1" style="margin-top: 0.65rem">
    <!--日历-->
    <div class="calendarDiv" >
      <div class="calendarTitle">
        <span @click="reduceTime(2)" class="lastYear"><img src="../../images/left2.png" alt=""></span>
        <span @click="reduceTime(1)" class="lastMonth"><img src="../../images/leftjiantou.png" alt=""></span>
        <span @click="chooseYear()"  class="time">{{new Date(changeTime).format('yyyy年MM月')}}</span>
        <span @click="addTime(1)" class="nextMonth"><img src="../../images/rightjiantou.png" alt=""></span>
        <span @click="addTime(2)" class="nextYear"><img src="../../images/right2.png"></span>
      </div>
      <table>
        <tr>
          <td>日</td>
          <td>一</td>
          <td>二</td>
          <td>三</td>
          <td>四</td>
          <td>五</td>
          <td>六</td>
        </tr>
        <tr  class="timeList" v-for="(item,index) in list">
          <td v-for="(item1,index1) in item.timeList"  @click="chooseDate(index,index1)"  :class="item1.isShow ? 'today' : new Date(item1.time).format('yyyyMMdd') === new Date().format('yyyyMMdd') ? 'nowDay' : new Date(item1.time).getMonth() !== new Date(changeTime).getMonth() ? 'activity' :'' " >
            <!--<span :class=" new Date(item1.time).format('yyyyMMdd') < new Date().format('yyyyMMdd') ? 'activityNum2' : 'activityNum' " v-show="item1.data"  >{{item1.data}}</span>-->
            <span class="date" >{{ new Date(item1.time).format('dd') }}</span>
            <div class="lineDiv">
              <div class="lineDiv">
                <div class="line2" v-for=" (item2,index2) in item1.lineArry">
                  <div v-show="item2.headerShow" class="lineHeader" :style="{backgroundColor:item2.color}"></div>
                  <hr  v-show="item2.bodyShow" class="lineBody" :style="{borderTop:colorFun(item2.color)}" :class="{ lineBodyWidth2 : (item2.footerShow && item2.headerShow ),  lineBodyWidth : (item2.footerShow || item2.headerShow )}"></hr>
                  <div v-show="item2.footerShow " class="lineFooter" :style="{backgroundColor:item2.color}"></div>
                </div>
              </div>



            </div>
          </td>
        </tr>
      </table>

    </div>
    <!--列表-->
    <div class="table-box" v-show="listShow" >
      <table style="width: 100%">
        <tr class="tab-head ">
          <td style="width:20%">活动名</td>
          <td style="width:16%" class="light">活动类型</td>
          <td style="width:16%" class="light">活动时间</td>
          <td style="width:16%" >参与人数</td>
        </tr>
        <tr v-for="(item,index) in activityList" :key="index"  :class="{bglight:index%2===1}" @click="toActDetail(item)">
          <td style="width:30%;position: relative">
            <span class="sign1" :style="{backgroundColor:item.actColor}" ></span>
            <span :class=" item.showCalendar ===0 ?'light' : '' " style="display: inline-block;width: 1.6rem;font-size: 0.2rem" >{{item.actName}}</span>
          </td>
          <td style="width:20%"><div><span class="light"><p style="margin: 0;padding:0;font-size: 0.2rem">{{item.typeName}}</p><p style="margin: 0;padding:0;font-size: 0.2rem">{{item.detailsName}}</p></span></div></td>
          <td style="width:15%" class="light"><p style="margin: 0;padding:0;font-size: 0.16rem">{{item.actDate}}</p> <p v-show="item.dayNum" style="margin: 0;padding:0;font-size: 0.2rem">{{item.dayNum}}</p></td>
          <td style="width:15%"><div><span :class=" item.showCalendar ===0 ?'light' : '' " >{{item.peopleNum}}</span></div></td>
        </tr>
      </table>
      <p v-show="activityList.length ===0 " style="width: 100%;text-align: center;height: 0.5rem;line-height: 0.8rem">
        暂无数据
      </p>
    </div>
  </div>
  <!--活动池-->
  <div v-show="chooseType ===2" style="width: 100%;background-color: #EEEEEE;padding-bottom: 1rem;margin-top: 0.9rem" >
    <div>
      <div v-for="(item,index) in actList"  class="activityDiv" @click="toPage(item)">
        <div class="activityName">
          <img src="../../images/time.png" alt="" >
          <p><strong>{{item.actTypeName}}</strong></p>
        </div>
        <p class="introduce" style="">{{item.actIntroduce}}</p>
        <div class="planDiv">
          <p>{{item.hihNum}}</p>
          <p>{{item.inThePlanNum}}</p>
        </div>
      </div>
    </div>
    <!--可安排活动-->
    <div class="titleDiv">
      <span class="line"></span>
      <span class="title">可安排的活动</span>
      <span class="line"></span>
    </div>

    <div v-show="actPlanList.length !==0">
      <div v-for="(item,index) in actPlanList" class="activityDiv"  @click="toPage(item)"  style="padding-bottom: 0.6rem">
        <div class="activityName">
          <img src="../../images/time.png" alt="" >
          <p><strong>{{item.actTypeName}}</strong></p>
        </div>
        <p class="introduce" style="">{{item.actIntroduce}}</p>
      </div>
    </div>
    <div v-show="actPlanList.length ===0">
      <p style="width: 100%;text-align: center;height: 1rem;line-height: 1rem;padding-bottom: 1rem">暂无可安排活动</p>
    </div>

  </div>
  <!--bar-->
  <two-nav currenturl="activity" :storename="storeName" ></two-nav>

</div>
<script src="../../js/echarts.common.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../common/timeCheck.js"></script>
<script src="../../js/mui.min.js"></script>
<script src="../../js/mui.picker.js"></script>
<script src="../../js/mui.dtpicker.js"></script>
<script src="../../common/nav.js"></script>

<script type="text/javascript">
  mui.init()
  var vm = new Vue({
    el: '#app',
    data: function() {
      return{
        storeName:'',
        storeId:'',
        toDate:'',
        fromDate:'',
        actnum:'',
        lastPage:'',
        dateType:'',
        currentShopObj:'',
        chooseType:1,  //1.活动计划  2.活动池
        list: [
          {"timeList":[{"time":1550937600000,"isShow":false,"lineArry":[{"color":"#db90c6","headerShow":true,"footerShow":false,"bodyShow":true,"actId":7,"actName":"ee","endTime":20190301,"actTimeType":0},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"}]},{"time":1551024000000,"isShow":false,"lineArry":[{"color":"#db90c6","headerShow":false,"footerShow":false,"bodyShow":true,"actId":7,"actName":"ee","endTime":20190301,"actTimeType":0},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"}]},{"time":1551110400000,"isShow":false,"lineArry":[{"color":"#db90c6","headerShow":false,"footerShow":false,"bodyShow":true,"actId":7,"actName":"ee","endTime":20190301,"actTimeType":0},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"}]},{"time":1551196800000,"isShow":false,"lineArry":[{"color":"#db90c6","headerShow":false,"footerShow":false,"bodyShow":true,"actId":7,"actName":"ee","endTime":20190301,"actTimeType":0},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"}]},{"time":1551283200000,"isShow":false,"lineArry":[{"color":"#db90c6","headerShow":false,"footerShow":false,"bodyShow":true,"actId":7,"actName":"ee","endTime":20190301,"actTimeType":0},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"}]},{"time":1551369600000,"isShow":true,"lineArry":[{"color":"#db90c6","headerShow":false,"footerShow":true,"bodyShow":true,"actId":7,"actName":"ee","endTime":20190301,"actTimeType":0},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"}]},{"time":1551456000000,"isShow":false,"lineArry":[{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"},{"color":"transparent","headerShow":false,"footerShow":false,"bodyShow":true,"actId":-1,"actName":"没有活动"}]}]}

        ],
        startDate:'',  //选定时间
        changeTime:'',  //变换的时间
        fromTime:'',   //日历的开始时间
        toTime:'',      //日历的结束时间
        actDay:[
          {
            "actId":9,
            "storeId":0,
            "actType":2,
            "actName":"新年 “猪事如意” 套餐",
            "actTimeType":3,
            "specialDay":0,
            "startTime":0,
            "endTime":0,
            "startDate":0,
            "endDate":0,
            "actColor":"#0",
            "actColorId":0,
            "dateNo":[
              20190131,
              20190201,
              20190202,
              20190203,
              20190204,
              20190205,
              20190206,
              20190207,
              20190208,
              20190209,
              20190210,
              20190211,
              20190212,
              20190213,
              20190214,
              20190215,
              20190216,
              20190217,
              20190218,
              20190219,
              20190220
            ]
          },
          {
            "actId":3,
            "storeId":0,
            "actType":4,
            "actName":"测试5",
            "actTimeType":0,
            "specialDay":0,
            "startTime":0,
            "endTime":0,
            "startDate":0,
            "endDate":0,
            "actColor":"#0",
            "actColorId":0,
            "dateNo":[
              20190207,
              20190208,
              20190209,
              20190210,
              20190211
            ]
          }
        ],   //日历上 有活动的日期 和 活动数
        activityList:[
          {
            "actId":9,
            "actName":"新年 “猪事如意” 套餐",
            "actType":2,
            "actTimeType":0,
            "specialDay":0,
            "actDate":"01.31-02.20",
            "peopleNum":"--",
            "actState":3,
            "typeName":"会员卡",
            "detailsName":"充值优惠",
            "dayNum":"每天",
            "showCalendar":1,
            "actColor":"#0b3ad4"
          },
        ],   // 当前时间的活动列表
        actList:[],   //活动池  列表
        actPlanList:[],  //可安排的列表
        show:true,
        lastList:[],
        listShow:false,
        originalLineArry:[],
      }
    },

    mounted: function() {
      var vm = this;
      mui.plusReady(function() {
        vm.receiveParams();
        vm.initTime()
      });
    },
    methods: {
      colorFun:function(params){
        return '1px dotted '+ params
      },
      receiveParams: function() {
        var sf = plus.webview.currentWebview();
        this.currentShopObj = sf.currentShopObj;
        this.storeId = sf.storeId
        this.storeName = sf.storeName
        this.toDate = sf.toDate
        this.fromDate = sf.fromDate
        this.actnum  = sf.actnum
        this.dateType  = sf.dateType

      },
//获取日历信息
      loadData:function() {
        var vm=this;
        var year=this.changeTime.getFullYear();
        var month=this.changeTime.getMonth();
//        当前月的1号
        var firstDay= new Date(year,month,1);
        var week=firstDay.getDay();
//       日历的第一天
        vm.fromTime=new Date(firstDay).getTime()-week*24*60*60*1000;
        vm.toTime=vm.fromTime+41*24*60*60*1000;
        var data={
          fromTime: new Date(vm.fromTime).getTime(),
          toTime: new Date(vm.toTime).getTime(),
          dayDate: vm.listShow ?  Number(new Date(vm.startDate).format('yyyyMMdd')) :  Number(new Date(vm.changeTime).format('yyyyMMdd')) ,
          storeId:vm.storeId,
        }
        config.ajax({
          url:'/act/getMonthActivity',
          data:{
            fromTime: new Date(vm.fromTime).getTime(),
            toTime: new Date(vm.toTime).getTime(),
            dayDate: vm.listShow ?  Number(new Date(vm.startDate).format('yyyyMMdd')) :  Number(new Date(vm.changeTime).format('yyyyMMdd')) ,
            storeId:vm.storeId,
          },
          success: function(res){
            console.log(JSON.stringify(res))
            vm.activityList=res.cardActivityCount.activityList;
            vm.actDay=res.cardActivityCount.monthDays;

            vm.changeDate()
          },
          error:function(res){
            mui.toast(res.errormsg)
          }
        })
      },
//获取活动池列表
      getActList:function(){
        var vm=this;
        config.ajax({
          url:'/act/getActivityPond',
          data:{
            storeId:vm.storeId,
          },
          success: function(res){
            vm.actList=res.activityPond.activityPonds;
            vm.actPlanList=res.activityPond.arrangableAct;
          },
          error:function(res){
            mui.toast(res.errormsg)
          }
        })
      },
//选择 计划池  活动加护
      choose:function(type){
        var  vm=this;
        if(type !==this.chooseType){
          this.chooseType=type;
          if(type ===2){
            vm.getActList()
          }
        }
      },
      initTime:function(){
        this.startDate=new Date();
        this.changeTime=this.startDate;
      },
// 选择日期
      chooseDate:function(index,index1){
        var vm=this;
        vm.list.forEach(function(item,index){
          item.timeList.forEach(function(time,ind){
            time.isShow=false;
          })
        })
        vm.list[index].timeList[index1].isShow=true;
        this.startDate=new Date(vm.list[index].timeList[index1].time);
        this.changeTime=this.startDate;
//        this.changeDate()
      },
// 获取日历列表
      changeDate:function () {
        var vm=this;
        var year=vm.changeTime.getFullYear();
        var month=vm.changeTime.getMonth();
        var firstDay= new Date(year,month,1);
        var week=firstDay.getDay();
        //       日历的第一天
        var day=new Date(firstDay).getTime()-week*24*60*60*1000;

        var list=[],timeList=[],time=0,allTime=[];
        vm.originalLineArry=[];
        var object={};

        vm.actDay.forEach(function(item,index){
          item.dateNo.forEach(function(item1,index1){

            if(object.actId !== item.actId  ){

              if( Number(new Date(day).format('yyyyMMdd')) === Number(item1)){
                object={
                  color:item.actColor,
                  headerShow:true,
                  footerShow:index1 === item.dateNo.length-1 ,
                  bodyShow:true,
                  actId:item.actId,
                  actName:item.actName,
                  endTime: Number(item.dateNo[item.dateNo.length-1]) ,
                  actTimeType:Number(item.actTimeType),   //0 特殊卡 每天都有  1.每周几 2.每月几 3. 生日（每天都有）
                };
                vm.originalLineArry.push(object)
              }
            }

          })
        });

        if(vm.originalLineArry.length < 4){
          for(var f=vm.originalLineArry.length ;f<4;f++){
            vm.originalLineArry.push({
              color:'transparent',
              headerShow:false,
              footerShow:false,
              bodyShow:true,
              actId:-1,
              actName:'没有活动',
            })
          }

        }else if(vm.originalLineArry.length > 4){
          vm.originalLineArry=[vm.originalLineArry[0],vm.originalLineArry[1],vm.originalLineArry[2],vm.originalLineArry[3],]
        };

        //循环获取日历时间数组
        for(var i=0;i<42;i++){
          var obj={};
          time=day+i*24*60*60*1000;
          allTime.push(time)
          obj.time=time;
          //判断是否是当前时间
          if( Number(new Date(time).format('yyyyMMdd'))  === Number(new Date(vm.startDate).format('yyyyMMdd')) ){
            obj.isShow=true
          }else{
            obj.isShow=false
          }

          //判断数组中是否 有活动 和 活动是否结束
          if(time === day){
          }else{
            vm.lineFun(time,0,[1,2,3]);
            vm.lineFun(time,1,[0,2,3]);
            vm.lineFun(time,2,[1,0,3]);
            vm.lineFun(time,3,[1,2,0]);
          }
          vm.$set(obj,'lineArry',JSON.parse(JSON.stringify(vm.originalLineArry)))

          timeList.push(obj);
          if(timeList.length === 7){
            list.push({
              timeList:timeList
            });
            timeList=[]
          }
        };





        //判断当前日历是否有选择的时间
        for(var k =0;k<allTime.length;k++){
          if( new Date(allTime[k]).format('yyyyMMdd') === new Date(vm.startDate).format('yyyyMMdd')){
            vm.listShow=true;
            break;
          }else{
            vm.listShow=false;
          }
        }

//        console.log(JSON.stringify(vm.actDay))
        console.log(JSON.stringify(list[0]))
        list.forEach(function(item,index){
          item.timeList.forEach(function(item1,index1){
            if(!item1.lineArry[0].headerShow){
              item.timeList[0].lineArry[0].headerShow=true;
            }
            if(!item1.lineArry[1].headerShow){
              item.timeList[0].lineArry[1].headerShow=true;
            }
            if(!item1.lineArry[2].headerShow){
              item.timeList[0].lineArry[2].headerShow=true;
            }
            if(!item1.lineArry[3].headerShow){
              item.timeList[0].lineArry[3].headerShow=true;
            }
            if(!item1.lineArry[3].footerShow){
              item.timeList[6].lineArry[0].footerShow=true;
            }
            if(!item1.lineArry[3].footerShow){
              item.timeList[6].lineArry[1].footerShow=true;
            }
            if(!item1.lineArry[3].footerShow){
              item.timeList[6].lineArry[2].footerShow=true;
            }
            if(!item1.lineArry[3].footerShow){
              item.timeList[6].lineArry[3].footerShow=true;
            }

          })

        })
        vm.list=list;
        vm.fromTime=vm.list[0].timeList[0].time
        vm.toTime=vm.list[5].timeList[6].time

      },
// 增加时间  type 1. 月  2 年
      addTime:function(type){
        var vm=this;
        var year=vm.changeTime.getFullYear();
        var month=vm.changeTime.getMonth(); // 0 是一月
//        var day=vm.startDate.getDate();
        var date=''
        if(type ===1){
          if(month ===11){
            date=(year+1)+'-'+1+'-'+1;
          }else{
            date=year+'-'+(month+2)+'-'+1;
          }
        }else if(type ===2){
          date=(year+1)+'-'+(month+1)+'-'+1
        }
        vm.changeTime=new Date(date)
      },
// 减少时间   type 1. 月  2 年
      reduceTime:function(type){
        var vm=this;
        var year=vm.changeTime.getFullYear();
        var month=vm.changeTime.getMonth(); // 0 是一
        var date=''
        if(type ===1){
          if(month ===0){
            date=(year-1)+'-'+12+'-'+1;
          }else{
            date=year+'-'+month+'-'+1;
          }
        }else if(type ===2){
          date=(year-1)+'-'+(month+1)+'-'+1
        }
        vm.changeTime=new Date(date)
      },
//选择年月
      chooseYear:function(){
        var  vm=this;
        var dtPicker = new mui.DtPicker({
          "type":"month",
          //设置初始时间
          'value':  new Date(vm.changeTime).format('yyyy-MM')
        });
        dtPicker.show(function (selectItems) {
          vm.changeTime= new Date(selectItems.y.value+'-'+selectItems.m.value+'-'+1)
        });

      },
// 活动池页面跳转
      toPage:function(item){
        var vm = this;
        var storeName=vm.storeName;
        var url='';
// 1.首冲活动 2.充值活动 3.福利  4.免费卡
        switch (item.actType ){
          case 1 : url= 'firstRechargeAct';break;
          case 2: url= "rechargeAct" ;break;
          case 3: url= "rewardAct" ;break;
          case 4: url= "specialCardActList" ;break;
        }
        mui.openWindow({
          url: '../'+url+'.html',
          id: url,
          styles: {
            titleNView: {
              titleText:  storeName ,
              titleColor: "#FFFFFF",
              titleSize: "17px",
              backgroundColor: "#FF6800",
              autoBackButton: true,
              buttons: [{
                fontWeight: 'normal',
                fontSize: '18px',
                float: 'right',
                fontSrc: "_www/fonts/iconfont.ttf", //wap2app内置字体文件
                text: "\ue602",
                onclick: function() {
                  var allPage = plus.webview.all()
                  var nowPage = plus.webview.getWebviewById('index')
                  for(var i = 0; i < allPage.length; i++) {
                    if(allPage[i].getURL() !== nowPage.getURL()) {
                      plus.webview.close(allPage[i]);
                    }
                  }
                }
              }],
              splitLine: {
                color: "#CCCCCC",
                height: "1px"
              }
            }
          },
          extras: {
            storeId: vm.storeId,
            storeName: vm.storeName,
            fromDate: vm.fromDate,
            toDate:vm.toDate,
            dateType:vm.dateType,
            actnum: vm.actnum,
            actType:item.actType,
            actId:item.actId,
          },
        });
      },
// 活动计划 跳转活动详情页面
      toActDetail:function(item){
        var url='';
//actType  1.首冲  2.充值 3.赠送（福利）
        switch (item.actType ){
          case 1 : url= 'rechargeActivityDetails';break;
          case 2: url= "rechargeActivityDetails" ;break;
          case 3: url= "activityWelfareDetails" ;break;
          case 4: url= "specialCardDetails" ;break;
        }

        var storeName=vm.storeName;
        mui.openWindow({
          url: '../'+url+'.html',
          id: url,
          styles: {
            titleNView: {
              titleText:  storeName ,
              titleColor: "#FFFFFF",
              titleSize: "17px",
              backgroundColor: "#FF6800",
              autoBackButton: true,
              buttons: [{
                fontWeight: 'normal',
                fontSize: '18px',
                float: 'right',
                fontSrc: "_www/fonts/iconfont.ttf", //wap2app内置字体文件
                text: "\ue602",
                onclick: function() {
                  var allPage = plus.webview.all()
                  var nowPage = plus.webview.getWebviewById('index')
                  for(var i = 0; i < allPage.length; i++) {
                    if(allPage[i].getURL() !== nowPage.getURL()) {
                      plus.webview.close(allPage[i]);
                    }
                  }
                }
              }],
              splitLine: {
                color: "#CCCCCC",
                height: "1px"
              }
            }
          },
          extras: {
            storeId: vm.storeId,
            storeName: vm.storeName,
            fromDate: vm.fromDate,
            toDate:vm.toDate,
            dateType:vm.dateType,
            actnum: vm.actnum,
            actType:item.actType,
            actId:item.actId,
            actState:item.actState,
          },
        });

      },
// 日历线的判断  time 当前时间 ind originalLineArry的当前下表   otherIndex=[] originalLineArry的其他3个下表
      lineFun:function(time,ind,otherIndex){
        var defaultLine={
          color:'transparent',
          headerShow:false,
          footerShow:false,
          bodyShow:true,
          actId:-1,
          actName:'没有活动',
        };
        var actLine=false
// 有活动  活动没结束
        if(vm.originalLineArry[ind].actId !==-1 && vm.originalLineArry[ind].endTime > Number(new Date(time).format('yyyyMMdd'))){
          if(vm.originalLineArry[ind].actTimeType ===2 ||  vm.originalLineArry[ind].actTimeType===1){
            vm.actDay.forEach(function(item,index){

              if(item.actId === vm.originalLineArry[ind].actId){
                for(var r=0;r<item.dateNo.length;r++){

                  if( Number(new Date(time).format('yyyyMMdd')) === Number(item.dateNo[r])){
                    vm.originalLineArry[ind]={
                      color:item.actColor,
                      headerShow:true,
                      footerShow:true,
                      bodyShow:true,
                      actId:item.actId,
                      actName:item.actName,
                      endTime: Number(item.dateNo[item.dateNo.length-1]) ,
                      actTimeType:Number(item.actTimeType),   //0 特殊卡 每天都有  1.每周几 2.每月几 3. 生日（每天都有）
                    };
                    break;
                  }else{
                    vm.originalLineArry[ind]={
                      color:'transparent',
                      headerShow:false,
                      footerShow:false,
                      bodyShow:true,
                      actId:-1,
                      actName:'没有活动',
                    }
                  }
                }

              }
            })
          }else{
            vm.originalLineArry[ind]={
              color:vm.originalLineArry[ind].color,
              headerShow:false,
              footerShow:false,
              bodyShow:true,
              actId:vm.originalLineArry[ind].actId,
              actName:vm.originalLineArry[ind].actName,
              endTime:vm.originalLineArry[ind].endTime ,
              actTimeType:vm.originalLineArry[ind].actTimeType,   //0 特殊卡 每天都有  1.每周几 2.每月几 3. 生日（每天都有）
            }
          }
// 有活动 活动最后一天

        }else if(vm.originalLineArry[ind].actId !==-1 && vm.originalLineArry[ind].endTime === Number(new Date(time).format('yyyyMMdd'))){

          if(vm.originalLineArry[ind].actTimeType ===2 ||  vm.originalLineArry[ind].actTimeType===1){
            vm.actDay.forEach(function(item,index){
              if(item.actId === vm.originalLineArry[ind].actId){
                for(var r=0;r<item.dateNo.length;r++){
                  if( Number(new Date(time).format('yyyyMMdd')) === Number(item.dateNo[r])){

                    vm.originalLineArry[ind]={
                      color:item.actColor,
                      headerShow:true,
                      footerShow:true,
                      bodyShow:true,
                      actId:item.actId,
                      actName:item.actName,
                      endTime: Number(item.dateNo[item.dateNo.length-1]) ,
                      actTimeType:Number(item.actTimeType),   //0 特殊卡 每天都有  1.每周几 2.每月几 3. 生日（每天都有）
                    };
                    break;
                  }else{
                    vm.originalLineArry[ind]={
                      color:'transparent',
                      headerShow:false,
                      footerShow:false,
                      bodyShow:false,
                      actId:-1,
                      actName:'没有活动',
                    }
                  }
                }
              }
            })
          }else{
            vm.originalLineArry[ind]={
              color:vm.originalLineArry[ind].color,
              headerShow:false,
              footerShow:true,
              bodyShow:true,
              actId:vm.originalLineArry[ind].actId,
              actName:vm.originalLineArry[ind].actName,
              endTime:vm.originalLineArry[ind].endTime ,
              actTimeType:vm.originalLineArry[ind].actTimeType,   //0 特殊卡 每天都有  1.每周几 2.每月几 3. 生日（每天都有）
            }
          }
// 活动结束了  补充其他活动 或者 添加默认白色  或者 //没有活动  添加活动 或者  默认白色
        }else if( ( vm.originalLineArry[ind].actId !==-1 && vm.originalLineArry[ind].endTime < Number(new Date(time).format('yyyyMMdd')) ) || vm.originalLineArry[ind].actId ===-1 ){
          var type=0;
          for(var l=0;l<vm.actDay.length;l++){
            //排除originalLineArry中另外3个活动
            if(vm.actDay[l].actId !== vm.originalLineArry[otherIndex[0]].actId && vm.actDay[l].actId !== vm.originalLineArry[otherIndex[1]].actId && vm.actDay[l].actId !== vm.originalLineArry[otherIndex[2]].actId  ){
              //判断当天是否有其他活动补充
              for(var e=0;e<vm.actDay[l].dateNo.length;e++){

                if(Number(vm.actDay[l].dateNo[e]) === Number( new Date(time).format('yyyyMMdd'))){

                  if(type ===0){
                    actLine={
                      color:vm.actDay[l].actColor,
                      headerShow:e === 0,
                      footerShow:e === vm.actDay[l].dateNo[e].length-1,
                      bodyShow:true,
                      actId:vm.actDay[l].actId,
                      actName:vm.actDay[l].actName,
                      endTime:vm.actDay[l].dateNo[vm.actDay[l].dateNo.length-1] ,
                      actTimeType:vm.actDay[l].actTimeType,   //0 特殊卡 每天都有  1.每周几 2.每月几 3. 生日（每天都有）
                    };
                    if(vm.actDay[l].actTimeType ===1 || vm.actDay[l].actTimeType ===2){
                      actLine.headerShow=true;
                      actLine.footerShow=true;
                    }
                  }
                  type +=1;
                }

              }
            }

            vm.originalLineArry[ind]= actLine  ? actLine : defaultLine;

          }


        }
      },



      //去同级的其他页面（收入，收币，返奖，出票，榜单，活动）
      toOtherPage: function(url) {
        var vm = this;
        var storeName = vm.storeName;
        mui.openWindow({
          url: './' + url + '.html',
          id: url,
          styles: {
            titleNView: {
              titleText: storeName,
              titleColor: "#FFFFFF",
              titleSize: "17px",
              backgroundColor: "#FF6800",
              autoBackButton: true,
              buttons: [{
                fontWeight: 'normal',
                fontSize: '18px',
                float: 'right',
                fontSrc: "_www/fonts/iconfont.ttf", //wap2app内置字体文件
                text: "\ue602",
                onclick: function() {
                  var allPage = plus.webview.all()
                  var nowPage = plus.webview.getWebviewById('index')
                  for(var i = 0; i < allPage.length; i++) {
                    if(allPage[i].getURL() !== nowPage.getURL()) {
                      plus.webview.close(allPage[i]);
                    }
                  }
                }
              }],
              splitLine: {
                color: "#CCCCCC",
                height: "1px"
              }
            }
          },
          extras: {
            storeId: vm.storeId,
            storeName: vm.storeName,
            fromDate: vm.fromDate,
            toDate: vm.toDate,
            dateType: vm.dateType,
            actnum: vm.actnum,
            lastPage: 'incomeItem',
          },
          createNew: true,
        });
        var self=plus.webview.currentWebview();
        setTimeout(function(){
          self.close('none');
        },1000)
      },

    },
    watch: {
      changeTime:function(){
        this.loadData()
      }
    }
  });
</script>
</body>

</html>